package com.zhuss.job.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.job.job.CreateJobBo;
import com.zhuss.bean.bo.job.job.DeleteJobBo;
import com.zhuss.bean.bo.job.job.UpdateJobBo;
import com.zhuss.bean.bo.job.job.wechat.CollectJobBo;
import com.zhuss.bean.bo.job.job.wechat.DelTopicJobBo;
import com.zhuss.bean.bo.job.job.wechat.ForwardJobBo;
import com.zhuss.bean.bo.job.job.wechat.ThumbJobBo;
import com.zhuss.bean.bo.job.job.wechat.TopicJobBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;

/**
 * job操作service（基本操作）
 * @author zhushanshuo
 * @Date 2020-02-05 15:59
 *
 */
@Component("jobOperateService")
public class JobOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("jobCreate")
	private Processor<Object, CreateJobBo> jobCreate;
	
	@Autowired
	@Qualifier("jobUpdate")
	private Processor<Object, UpdateJobBo> jobUpdate;
	
	@Autowired
	@Qualifier("jobDelete")
	private Processor<Object, DeleteJobBo> jobDelete;
	
	@Autowired
	@Qualifier("jobThumb")
	private Processor<Object, ThumbJobBo> jobThumb;
	
	@Autowired
	@Qualifier("jobCollect")
	private Processor<Object, CollectJobBo> jobCollect;
	
	@Autowired
	@Qualifier("jobForward")
	private Processor<Object, ForwardJobBo> jobForward;
	
	@Autowired
	@Qualifier("jobTopic")
	private Processor<Object, TopicJobBo> jobTopic;
	
	@Autowired
	@Qualifier("jobDelThumb")
	private Processor<Object, ThumbJobBo> jobDelThumb;
	
	@Autowired
	@Qualifier("jobDelCollect")
	private Processor<Object, CollectJobBo> jobDelCollect;
	
	@Autowired
	@Qualifier("jobDelForward")
	private Processor<Object, ForwardJobBo> jobDelForward;
	
	@Autowired
	@Qualifier("jobDelTopic")
	private Processor<Object, DelTopicJobBo> jobDelTopic;
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws WpsException {
		
		CreateJobBo bo = (CreateJobBo) param;
		
		jobCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws WpsException {
    	
		UpdateJobBo bo = (UpdateJobBo) param;
		
		jobUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws WpsException {
		
		DeleteJobBo bo = (DeleteJobBo) param;
		
		jobDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void thumb(Object param) throws WpsException {
		
		ThumbJobBo bo = (ThumbJobBo) param;
		
		jobThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void collect(Object param) throws WpsException {
		
		CollectJobBo bo = (CollectJobBo) param;
		
		jobCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void forward(Object param) throws WpsException {
		
		ForwardJobBo bo = (ForwardJobBo) param;
		
		jobForward.process(bo);
		
		return null;
	}
	
	/**
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void topic(Object param) throws WpsException {
		
		TopicJobBo bo = (TopicJobBo) param;
		
		jobTopic.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delThumb(Object param) throws WpsException {
		
		ThumbJobBo bo = (ThumbJobBo) param;
		
		jobDelThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delCollect(Object param) throws WpsException {
		
		CollectJobBo bo = (CollectJobBo) param;
		
		jobDelCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delForward(Object param) throws WpsException {
		
		ForwardJobBo bo = (ForwardJobBo) param;
		
		jobDelForward.process(bo);
		
		return null;
	}
	
	/**
	 * 删
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delTopic(Object param) throws WpsException {
		
		DelTopicJobBo bo = (DelTopicJobBo) param;
		
		jobDelTopic.process(bo);
		
		return null;
	}
	
}

